import { _decorator, Component, KeyCode } from 'cc';
import { InputUtil } from 'db://assets/component/input/InputUtil';
const { ccclass, property } = _decorator;

@ccclass('InputTest')
export class InputTest extends Component {
    count = 0;
    start() {
        this.test2();
    }

    test1() {
        const input = InputUtil.Instance();
        input.on(KeyCode.KEY_W, () => {
            console.log('W', this.count++);
        });

        input.on(KeyCode.KEY_S, () => {
            console.log('S', this.count--);
        });

        input.on(KeyCode.KEY_W, () => {
            console.log('what');
        });
    }

    test2() {
        const inputU = InputUtil.Instance();
        inputU.addEvent(KeyCode.NUM_1, () => {
            console.log('n1');
        });
        inputU.addEvent(KeyCode.NUM_1, () => {
            console.log('N1');
        });
        inputU.addEvent(KeyCode.NUM_2, () => {
            console.log('N2');
        });
    }

    update(deltaTime: number) {}
}
